﻿using Xejen.Ipc.Framework;
using Xejen.Ipc.Framework.Flows;
using System;

namespace Xejen.Ipc.Framework.Extensions
{
    /// <summary>
    /// 表示流程构建器
    /// </summary>
    /// <creator>marc</creator>
    public interface IFlowBuilder<TData>
        where TData : new()
    {
        /// <summary>
        /// 流程方法体
        /// </summary>
        Func<IBuilderFactory<TData>, IFlow<TData>> Body { get; set; }

        /// <inheritdoc cref="IFlow{TData}.Started"/>
        Action<FlowEventArgs<TData>> Started { get; set; }
        /// <inheritdoc cref="IFlow{TData}.Paused"/>
        Action<FlowEventArgs<TData>> Paused { get; set; }
        /// <inheritdoc cref="IFlow{TData}.Resumed"/>
        Action<FlowEventArgs<TData>> Resumed { get; set; }
        /// <inheritdoc cref="IFlow{TData}.Stopped"/>
        Action<FlowEventArgs<TData>> Stopped { get; set; }
        /// <inheritdoc cref="IFlow{TData}.CycleCompleted"/>
        Action<FlowEventArgs<TData>> CycleCompleted { get; set; }
        /// <inheritdoc cref="IFlow{TData}.ScanIntervalExceeded"/>
        Action<ScanIntervalExceededEventArgs<TData>> ScanIntervalExceeded { get; set; }
        /// <inheritdoc cref="IFlow{TData}.Error"/>
        Action<ErrorEventArgs<TData>> Error { get; set; }

        /// <summary>
        /// 针对流程做出额外的一些特殊处理
        /// </summary>
        Action<IFlow<TData>> Execution { get; set; }

        /// <summary>
        /// 创建流程
        /// </summary>
        /// <returns></returns>
        IFlow<TData> CreateFlow();
    }
}